package com.xja.shoppingmall.controller;

import com.xja.shoppingmall.annotation.IgnoreResponseAdvice;
import com.xja.shoppingmall.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * @author CHENCHEN
 * @title
 * @createTime 2021-12-1520:07
 */
@Slf4j
@Api(tags = "订单微服务功能接口")
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @ApiOperation(value = "创建订单", notes = "根据 商品Id创建订单",
            httpMethod = "POST")
    @IgnoreResponseAdvice
    @PostMapping("createOrder/{id}")
    public String createOrder(@RequestHeader("authority") String token,
                              @PathVariable("id") Long goodsId) throws Exception {
        log.info("request id , token : [{}]", goodsId, token);
        return orderService.createOrder(token, goodsId);
    }
}
